package cn.xiaobai.config;

import cn.xiaobai.interceptor.JWTInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器配置
 *
 * @Author yangdaji
 * @Date 2024/2/24
 * @PackageName cn.xiaobai.config
 * @ClassName InterceptorConfig
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册声明的拦截器
        registry.addInterceptor(new JWTInterceptor())
                .addPathPatterns("/user/data")      // 对数据获取接口进行拦截
                .excludePathPatterns("/user/login"); // 放行 登录接口
    }
}
